package com.example.demo.mapper;

import com.example.demo.entity.UserFollower;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 第五小组
 * @since 2021-08-10
 */
public interface UserFollowerMapper extends BaseMapper<UserFollower> {
    @Select("SELECT COUNT(*) as count  FROM user_follower  WHERE follower_level=0 UNION ALL\n" +
            "                        SELECT COUNT(*)  FROM user_follower  WHERE follower_level=1 UNION ALL \n" +
            "                        SELECT COUNT(*)  FROM user_follower  WHERE follower_level=2  UNION ALL \n" +
            "                        SELECT COUNT(*)  FROM user_follower  WHERE follower_level=3 UNION ALL \n" +
            "                        SELECT COUNT(*)  FROM user_follower  WHERE follower_level=4 UNION ALL \n" +
            "              SELECT COUNT(*)  FROM user_follower  WHERE  follower_level=5")
    public List<String> level_count();

    @Select("SELECT COUNT(*) as count  FROM user_follower  WHERE follower_vip>0 UNION ALL\n" +
            "SELECT COUNT(*) as count  FROM user_follower  WHERE follower_vip=0")
    public List<String> vip_count();

    @Select("SELECT COUNT(*) as count  FROM user_follower  WHERE follower_sex='男' UNION ALL\n" +
            "SELECT COUNT(*) as count  FROM user_follower  WHERE follower_sex='女' UNION ALL\n" +
            "SELECT COUNT(*) as count  FROM user_follower  WHERE follower_sex='保密'")
    public List<String> sex_count();

    @Select("SELECT COUNT(*) FROM user_follower where DATEDIFF(NOW(),follower_time) DIV 365 >= 1 UNION ALL\n" +
            "SELECT COUNT(*) FROM user_follower where DATEDIFF(NOW(),follower_time) DIV 180 >= 1 AND DATEDIFF(NOW(),follower_time) DIV 365 = 0 UNION ALL\n" +
            "SELECT COUNT(*) FROM user_follower where DATEDIFF(NOW(),follower_time) DIV 30 >= 1 AND DATEDIFF(NOW(),follower_time) DIV 180 = 0 UNION ALL\n" +
            "SELECT COUNT(*) FROM user_follower where DATEDIFF(NOW(),follower_time) DIV 30 = 0")
    public List<String> time_count();

}
